<template>
  <div
    class="search-com"
    :style="{height: height+'px', 'border-radius': height/2 + 'px', width: width ? width + 'px' : 'auto'}"
  >
    <input
      type="text"
      :value="value"
      v-bind="$attrs"
      @input="$emit('input', $event.target.value)"
      @change="$emit('change', $event.target.value)"
      @keyup.enter="$emit('submit', $event.target.value)"
    />
    <!-- <el-select
      :value="value"
      v-bind="$attrs"
      v-if="type === 'select'"
      size="small"
      placeholder="选择公司"
      @change="$emit('change', $event.target.value)"
    >
      <el-option v-for="l in list" :value="l[itemKey]" :key="l[itemKey]">{{ l.name }}</el-option>
    </el-select> -->
    <div class="icon" @click="$emit('submit', value)">
      <i class="el-icon-search search"></i>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: String,
      default: ""
    },
    height: {
      type: Number,
      default: 32
    },
    width: {
      type: [Number, String],
      default: 0
    },
  }
};
</script>

<style lang="scss" scoped>
.search-com {
  display: inline-flex;
  justify-content: flex-start;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(237, 237, 237, 1);
  background: #fbfbfb;
  height: 32px;
  font-size: 14px;
  min-width: 220px;
}
.search{
  color: #f2f6fc !important;
}
input {
  height: 100%;
  border: 0;
  color: #333;
  flex: 1;
  padding: 0 14px;
  box-sizing: border-box;
}
.icon {
  width: 44px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1682e6;
  color: #f2f6fc !important;
  flex-shrink: 0;
  cursor: pointer;
  &:hover {
    background: #aaa;
  }
}
</style>
